<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*,model.*,util.*,control.*"%>
<page import="others.java">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<%
	request.setCharacterEncoding("utf-8");
	/*
	*查看用户名是否存在 
	*@author vinllen
	*2011-12-6
	*/
	String userN = ParamUtil.getString(request,"userN");
	others xx = new others();
	if(xx.IsUserExist(userN)) { 
	%>
<script language="javascript">
	     alert("用户名已存在");
	     window.location.href="student_add.jsp";
	     </script>
<%
	return ;
	}
	String pas = ParamUtil.getString(request,"pas");
	String sna = ParamUtil.getString(request,"sna");
	String sx = ParamUtil.getString(request,"sx");
	String sc = ParamUtil.getString(request,"sc");
	String cl = ParamUtil.getString(request,"cl");
	String ma = ParamUtil.getString(request,"ma");
	String al = ParamUtil.getString(request,"al");
	if(userN==null||pas==null||userN.length()==0||pas.length()==0){
	%>
<script language="javascript">
	     alert("用户名密码不能为空");
	     window.location.href="student_add.jsp";
	     </script>
<%
	}else{

	Student student = new Student();
	StudentControl pc = new StudentControl();
	
	student.setUsername(userN);
	
	student.setStudentName(sna);
	student.setPassword(pas);
	student.setSex(sx);
	student.setSchool(sc);
	student.setClasses(cl);
	student.setMajor(ma);
	student.setAlt1(al);
	
	if(pc.insertStudent(student))
	{%>
		<script language="javascript">
	     alert("添加成功");
	     window.location.href="http://localhost:8080/SAT/index.jsp";
	     </script>
	<%}else{%>
	<script language="javascript">
	     alert("添加失败");
	     window.location.href="student_add.jsp";
	     </script>
	<%}//else
	}//else
	%>
	


</body>
</html>
